#ifndef __MMNGR_VIRTUAL_PTE_H_f57dbdf4eeb6488ba57a26c18f8494d3__
#define __MMNGR_VIRTUAL_PTE_H_f57dbdf4eeb6488ba57a26c18f8494d3__

#include "stdint.h"
#include "mmngr_phys.h"

#define MAX_PTE_NUMBER 1024

enum PAGE_PTE_FLAGS {

	I86_PTE_PRESENT			=	1,			//0000000000000000000000000000001
	I86_PTE_WRITABLE		=	2,			//0000000000000000000000000000010
	I86_PTE_USER			=	4,			//0000000000000000000000000000100
	I86_PTE_WRITETHOUGH		=	8,			//0000000000000000000000000001000
	I86_PTE_NOT_CACHEABLE	=	0x10,		//0000000000000000000000000010000
	I86_PTE_ACCESSED		=	0x20,		//0000000000000000000000000100000
	I86_PTE_DIRTY			=	0x40,		//0000000000000000000000001000000
	I86_PTE_PAT				=	0x80,		//0000000000000000000000010000000
	I86_PTE_CPU_GLOBAL		=	0x100,		//0000000000000000000000100000000
	I86_PTE_LV4_GLOBAL		=	0x200,		//0000000000000000000001000000000
   	I86_PTE_FRAME			=	0x7FFFF000 	//1111111111111111111000000000000
};

typedef uint32_t page_table_entry;

struct page_table
{
	page_table_entry pde[MAX_PTE_NUMBER];
};

void mmngr_virtual_pte_set_attri(page_table_entry *entry,uint32_t flags);

void mmngr_virtual_pte_unset_attri(page_table_entry *entry,uint32_t flags);

void mmngr_virtual_pte_set_frame(page_table_entry *entry,uint32_t addr);

uint32_t mmngr_virtual_pte_address_to_index(uint32_t addr);

page_table_entry *mmngr_virtual_pte_lookup_entry(page_table *p,uint32_t addr);

void mmngr_virtual_pte_clear(page_table *p);

page_table *mmngr_virtual_pte_create();

bool mmngr_virtual_pte_is_writeable(page_table_entry *entry);

bool mmngr_virtual_pte_is_present(page_table_entry *entry);

uint32_t mmngr_virtual_pte_get_frame(page_table_entry *entry);
#endif